home *** CD-ROM | disk | FTP | other *** search
- '==========================================================================
- ' Updated 5/21/91
- '
- ' Edit window routine using BIOS video routines.
- 'Give the routine an existing string to edit and it edits it.
- ' Don't give an existing string, and a new string is returned.
- ' The Filter$ is used to select the permissible values that
- ' can be returned. If you want all keystrokes to be returned, except
- ' those with an ASCII value of less than 32, then make Filter$ a null
- ' string. Also ignores all extended keys (other than Shift-Tab). Invalid
- ' keys trigger a beep.
- '
- 'Inputs:
- ' Row% = Row on screen for start of edit box. Range not checked
- ' Col% = Col on screen for edit box.
- ' Length% = Lenth of row in number of columns, max allowed is
- ' 80 characters.
- ' Attr% = color of edit box (Background Color * 16 + Foreground Color)
- ' This corresponds to the actual CRT format, blinking is allowed.
- ' Inputt$ = original input string, not checked for invalid characters
- ' Filter$ = The string used to filter out bad keystrokes and only
- ' allow the keystrokes setforth in the Filter$
- ' Exitkey% = is keystroke used to exit routine. Only keys recognized are
- ' Enter, ESC, TAB and Shift-TAB
- '
- 'Following editing keys are recognized:
- ' Home = move cursor to far left of string
- ' End = move cursor to far right of string
- ' Ins = toggles the insert mode cursor. Default is Ins on w/ a big
- ' cursor (opposite of QB.EXE, because QB.EXE got it backwards).
- ' Left arrow = move cursor left, if at left margin beep
- ' Right arrow = move cursor right, if at right margin beep
- ' Backspace = move cursor left, erasing character to left of cursor. if
- ' at left margin beep
- ' Del = erase character under cursor, don't move cursor, but move
- ' portion of string from the cursor right, left one character
- '
- 'Output:
- ' A string with a LEN <= Length, with trailing spaces removed. The
- ' output string is a normal variable length string.
- 'Not sure why you would want to do it, but with a proper Filter$, could
- 'accept input using ALT-SHIFT numeric keypad to enter graphics characters.
- '
- 'This demo is not copywrited, however the MASM source code is copyrighted.
- '==========================================================================
- DEFINT A-Z
- DECLARE FUNCTION EDITOR$ (BYVAL ROW%, BYVAL COL%, BYVAL Length%, BYVAL Attr%, Inputt$, Filter$, ExitKey%)
- 'tells whether video is using a color or mono port so can guess at display
- 'type and proper color choices.
- DECLARE FUNCTION INCOLOR% ()
-
- CONST TextFilter$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz"
- CONST PhoneFilter$ = "1234567890 ()-"
-
- CHR34$ = CHR$(34)
-
- IF INCOLOR% THEN
- COLOR 7, 1
- Attr = &H3E 'Yellow on Blue
- ELSE
- COLOR 7, 0
- Attr = &H70 'Inverse video
- END IF
-
- CLS
- ROW = 2: COL = 20: Length = 40
- Inputt$ = "This is a test!"
- Temp$ = EDITOR$(ROW%, COL%, Length%, Attr%, Inputt$, TextFilter$, ExitKey%)
-
- LOCATE 4, 3
- PRINT "I got "; CHR34$; Temp$; CHR34$; "."
- LOCATE 5, 3
- PRINT "Length of result string was"; STR$(LEN(Temp$)); "."
- LOCATE 6, 3
- PRINT "The Exit key was ";
- GOSUB NameKey
- PRINT T$; "."
-
- DO 'pause until user strikes a key
- LOOP UNTIL LEN(INKEY$)
- 'Above is much faster than
- 'do
- 'loop until inkey$ <> ""
-
- CLS
- ROW = 2: COL = 20: Length = 40
- Inputt$ = "(412) 561-0950"
- Temp$ = EDITOR$(ROW%, COL%, Length%, Attr%, Inputt$, PhoneFilter$, ExitKey%)
-
- LOCATE 4, 3
- PRINT "I got "; CHR34$; Temp$; CHR34$; "."
- LOCATE 5, 3
- PRINT "Length of result string was"; STR$(LEN(Temp$)); "."
- LOCATE 6, 3
- PRINT "The Exit key was ";
- GOSUB NameKey
- PRINT T$; "."
-
- END
-
- 'A gosub is used to save space in the .EXE file. Gosub's are fairly fast
- 'becuase they use a near call rather than a far call.
- NameKey:
- SELECT CASE ExitKey%
- CASE 13
- T$ = "Enter"
- CASE 9
- T$ = "Tab"
- CASE 15
- T$ = "Shift-Tab"
- CASE 27
- T$ = "Escape"
- CASE ELSE
- T$ = "Invalid"
- END SELECT
- RETURN
-